﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/WithoutPermBasic.Master" AutoEventWireup="true" CodeBehind="PrintDelivery.aspx.cs" Inherits="PMS.UI.CM.PrintDelivery" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        
        var Id = com.get.Id;
        var deliData = undefined;
        var companyData = undefined;
        $(function () {

            //加载客户信息
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "/Logic/CM/BottleDeliveryAjax.aspx?method=GetDeliveryForPrint",
                data: { "ID": Id },
                asyn: false,
                success: function (data) {
                    deliData = data.DeliveryData;
                    companyData = data.CompanyData;
                    //加载客户信息区
                    $("#Code").html(deliData.Code);
                    $("#CustomerNameA").html(deliData.CustomerName);
                    $("#ReceiveAddress").html(deliData.ReceiveAddress);
                    $("#SignDate").html(deliData.DeliveryDate);
                    $("#ContactPerson").html(companyData.Person);
                    $("#ContactPhone").html(companyData.MobilePhone);
                    $("#ProductOrderCode").html(deliData.ProductOrderCode);
                    $("#FillPerson").html(deliData.FillPersonName);
                    
                    //加载财务信息区
                    $("#InvoiceNo").html('');
                    $("#InvoiceMoney").html('');
                    //加载产品信息
                    $.ajax({
                        type: "POST",
                        dataType: "json",
                        url: "/Logic/CM/BottleDeliveryAjax.aspx?method=GetProdDetailForDeliveryPrint",
                        data: { "ID": Id },
                        asyn: false,
                        success: function (pData) {
                            LoadDetailData(pData);
                        }
                    });
                }
            });

            $("#btnPrint").click(function () {
                LoadInputData();

                $("#divPrint").print({
                    globalStyles: true,//是否包含父文档的样式，默认为true
                    mediaPrint: false,//是否包含media='print'的链接标签。会被globalStyles选项覆盖，默认为false
                    stylesheet: null,//外部样式表的URL地址，默认为null
                    noPrintSelector: ".no-print",//不想打印的元素的jQuery选择器，默认为".no-print"
                    iframe: true,//是否使用一个iframe来替代打印表单的弹出窗口，true为在本页面进行打印，false就是说新开一个页面打印，默认为true
                    append: null,//将内容添加到打印内容的后面
                    prepend: null,//将内容添加到打印内容的前面，可以用来作为要打印内容
                    deferred:
                 $.Deferred(

                        )//回调函数
                });
            });
        })

        function LoadDetailData(data) {
            var content = "";
            var num40 = 0;
            var num8 = 0;
            var num4 = 0;
            var sum = 0;
            for (var i = 0; i < data.length; i++) {
                content += "<tr>";
                content += "<td style='font-size:16px; text-align:center'>";
                content += i + 1;
                content += "</td>";

                content += "<td style='font-size:16px'>";
                content += data[i].TechParams;
                content += "</td>";

                content += "<td style='font-size:16px; text-align:center'>";
                content += data[i].OrderCount;
                content += "</td>";

                content += "<td style='font-size:16px; text-align:center'>";
                content += data[i].BottleVolume;
                content += "</td>";


                content += "<td style='font-size:16px; text-align:center'>";
                if (data[i].IsNewBottle == '0') content += "新瓶";
                else if (data[i].IsNewBottle == '1') content += "旧瓶";
                content += "</td>";

                content += "</tr>";

                sum += data[i].OrderCount;
                if (data[i].BottleVolume == 40) num40 += data[i].OrderCount;
                else if (data[i].BottleVolume == 8) num8 += data[i].OrderCount;
                else if (data[i].BottleVolume == 4) num4 += data[i].OrderCount;
            }
      
            $("#detailBody").html("");
            $("#detailBody").append(content);
            
            var numOther = sum - num40 - num8 - num4;
            if (num40 > 0) $("#lbSF40").html(num40);
            if (num8 > 0) $("#lbSF8").html(num8);
            if (num4 > 0) $("#lbSF4").html(num4);
            if (numOther > 0) $("#lbSF").html(numOther);
            $("#lbSF40").show();
            $("#lbSF8").show();
            $("#lbSF4").show();
            $("#lbSF").show();
        }

        function LoadInputData() {
            $("#lbSH40").html($("#lbSH40Input").val());
            $("#lbSH40").show();
            $("#lbSH40Input").hide();

            $("#lbSH8").html($("#lbSH8Input").val());
            $("#lbSH8").show();
            $("#lbSH8Input").hide();

            $("#lbSH4").html($("#lbSH4Input").val());
            $("#lbSH4").show();
            $("#lbSH4Input").hide();

            $("#lbSH").html($("#lbSHInput").val());
            $("#lbSH").show();
            $("#lbSHInput").hide();

            $("#lbZY40").html($("#lbZY40Input").val());
            $("#lbZY40").show();
            $("#lbZY40Input").hide();

            $("#lbZY8").html($("#lbZY8Input").val());
            $("#lbZY8").show();
            $("#lbZY8Input").hide();

            $("#lbZY4").html($("#lbZY4Input").val());
            $("#lbZY4").show();
            $("#lbZY4Input").hide();

            $("#lbZY").html($("#lbZYInput").val());
            $("#lbZY").show();
            $("#lbZYInput").hide();

            $("#lbKH40").html($("#lbKH40Input").val());
            $("#lbKH40").show();
            $("#lbKH40Input").hide();

            $("#lbKH8").html($("#lbKH8Input").val());
            $("#lbKH8").show();
            $("#lbKH8Input").hide();

            $("#lbKH4").html($("#lbKH4Input").val());
            $("#lbKH4").show();
            $("#lbKH4Input").hide();

            $("#lbKH").html($("#lbKHInput").val());
            $("#lbKH").show();
            $("#lbKHInput").hide();
        }
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceToorbar" runat="server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <input type="button" id="btnPrint" value="打印" style="height: 28px; width: 100px" />
    <div id="divPrint" style="margin-top: 20px; width: 960px">
        <div id="divBZWZ" style=" text-align: center; width:800px; margin-left:40px">
            <label style="font-size: 30px; font-weight: bold; font-family: Simsun,Times New Roman; ">杭州新世纪混合气体有限公司送（提）货单</label>
        </div>
        <div class="clear" style="height: 10px"></div>
        <span style="font-size: 16px; float: right; font-family: Simsun; margin-right: 40px">单据号：<span style="font-size: 16px; float: right; font-family: Simsun;" id="Code"></span></span><br />

        <table id="headTab" style="word-wrap: break-word; word-break: break-all; border-bottom: hidden">
            <tr>
                <td style="width: 800px; font-size: 16px; text-align: center" colspan="5">客户信息区</td>
            </tr>
            <tbody>
                <tr>
                    <td style="width: 100px; font-size: 16px; text-align: center">客户名称：</td>
                    <td style="width: 400px; font-size: 16px; text-align: center"><span style="font-size: 16px; font-family: Simsun;" id="CustomerNameA"></span></td>
                    <td style="width: 100px; font-size: 16px; text-align: center">派件日期：</td>
                    <td style="width: 200px; text-align: center" colspan="2"><span style="font-size: 16px; font-family: Simsun;" id="SignDate"></span></td>
                </tr>
                <tr>
                    <td style="width: 100px; font-size: 16px; text-align: center">送货地址：</td>
                    <td style="width: 700px; text-align: center" colspan="4"><span style="font-size: 16px; font-family: Simsun;" id="ReceiveAddress"></span></td>
                </tr>
                <tr>
                    <td style="width: 100px; font-size: 16px; text-align: center">联系人/电话：</td>
                    <td style="width: 400px; font-size: 16px; text-align: center">
                        <span style="font-size: 16px; font-family: Simsun;" id="ContactPerson"></span>
                        <span style="font-size: 16px; font-family: Simsun;">/</span>
                        <span style="font-size: 16px; font-family: Simsun;" id="ContactPhone"></span>
                    </td>
                    <td style="width: 100px; font-size: 16px; text-align: center">生产订单号：</td>
                    <td style="width: 200px; text-align: center" colspan="2">
                        <span style="font-size: 16px; font-family: Simsun;" id="ProductOrderCode"></span>
                    </td>
                </tr>
            </tbody>
        </table>

        <table id="tbDetail" style="word-wrap: break-word; word-break: break-all;border-bottom: hidden">
            <tr>
                <td style="width: 800px; font-size: 16px; text-align: center" colspan="5">产品信息区</td>
            </tr>
            <tr>
                <td style="width: 100px; font-size: 16px; text-align: center">序号</td>
                <td style="width: 400px; font-size: 16px; text-align: center">气体组分及浓度</td>
                <td style="width: 100px; font-size: 16px; text-align: center">数量/瓶</td>
                <td style="width: 100px; font-size: 16px; text-align: center">规格/L</td>
                <td style="width: 100px; font-size: 16px; text-align: center">新/旧瓶</td>
            </tr>
            <tbody id="detailBody">
            </tbody>
        </table>

        <table id="tbBottle" style="word-wrap: break-word; word-break: break-all;border-bottom: hidden">
            <tr>
                <td style="width: 800px; font-size: 16px; text-align: center" colspan="5">气瓶信息区</td>
            </tr>
            <tbody>
                <tr>
                    <td style="width: 100px; font-size: 16px; text-align: center">实发满瓶数：</td>
                    <td style="width: 700px; font-size: 16px; text-align: center" colspan="4">
                        <span style="font-size: 16px; font-family: Simsun;" id="lblSFMPS">
                        40L: <label style="font-size: 16px; display: none; width: 16px" id="lbSF40">/</label>支；
                        8L：<label style="font-size: 16px; display: none; width: 16px" id="lbSF8">/</label> 支； 
                        4L：<label style="font-size: 16px; display: none; width: 16px" id="lbSF4">/</label> 支；
                        其他：<label style="font-size: 16px; display: none; width: 16px" id="lbSF"></label> </span>
                    </td>
                </tr>
                <tr>
                    <td style="width: 100px; font-size: 16px; text-align: center">收回空瓶数：</td>
                    <td style="width: 700px; font-size: 16px; text-align: center" colspan="4">
                        <span style="font-size: 16px; font-family: Simsun;" id="lblSHKPS">40L:
                        <label style="font-size: 16px; display: none;" id="lbSH40">/</label> 
                        <input id="lbSH40Input" style="font-family: SimSun; font-size: 16px; text-align: center; width: 16px" />  
                        支； 8L：
                        <label style="font-size: 16px; display: none;" id="lbSH8">/</label> 
                        <input id="lbSH8Input" style="font-family: SimSun; font-size: 16px; text-align: center; width: 16px" />
                        支； 4L：
                        <label style="font-size: 16px; display: none;" id="lbSH4">/</label> 
                        <input id="lbSH4Input" style="font-family: SimSun; font-size: 16px; text-align: center; width: 16px" />
                        支； 其他：
                        <label style="font-size: 16px; display: none;" id="lbSH"></label> 
                        <input id="lbSHInput" style="font-family: SimSun; font-size: 16px; text-align: center; width: 16px" />
                        </span>
                    </td>
                </tr>
                <tr>
                    <td style="width: 100px; font-size: 16px; text-align: center">结余租用气瓶数：</td>
                    <td style="width: 700px; font-size: 16px; text-align: center" colspan="4">
                        <span style="font-size: 16px; font-family: Simsun;" id="lblZYQPS">40L:
                        <label style="font-size: 16px; display: none;" id="lbZY40">/</label> 
                        <input id="lbZY40Input" style="font-family: SimSun; font-size: 16px; text-align: center; width: 16px" />  
                        支； 8L：
                        <label style="font-size: 16px; display: none;" id="lbZY8">/</label> 
                        <input id="lbZY8Input" style="font-family: SimSun; font-size: 16px; text-align: center; width: 16px" />
                        支； 4L：
                        <label style="font-size: 16px; display: none;" id="lbZY4">/</label> 
                        <input id="lbZY4Input" style="font-family: SimSun; font-size: 16px; text-align: center; width: 16px" />
                        支； 其他：
                        <label style="font-size: 16px; display: none;" id="lbZY"></label> 
                        <input id="lbZYInput" style="font-family: SimSun; font-size: 16px; text-align: center; width: 16px" />
                        </span>
                    </td>
                </tr>
                <tr>
                    <td style="width: 100px; font-size: 16px; text-align: center">结余客户余瓶数：</td>
                    <td style="width: 700px; font-size: 16px; text-align: center" colspan="4">
                        <span style="font-size: 16px; font-family: Simsun;" id="lblKHYPS">40L: 
                        <label style="font-size: 16px; display: none;" id="lbKH40">/</label> 
                        <input id="lbKH40Input" style="font-family: SimSun; font-size: 16px; text-align: center; width: 16px" />  
                        支； 8L：
                        <label style="font-size: 16px; display: none;" id="lbKH8">/</label> 
                        <input id="lbKH8Input" style="font-family: SimSun; font-size: 16px; text-align: center; width: 16px" />
                        支； 4L：
                        <label style="font-size: 16px; display: none;" id="lbKH4">/</label> 
                        <input id="lbKH4Input" style="font-family: SimSun; font-size: 16px; text-align: center; width: 16px" />
                        支； 其他：
                        <label style="font-size: 16px; display: none;" id="lbKH"></label> 
                        <input id="lbKHInput" style="font-family: SimSun; font-size: 16px; text-align: center; width: 16px" />
                        </span>
                    </td>
                </tr>
            </tbody>
        </table>

        <table id="tbFinance" style="word-wrap: break-word; word-break: break-all;border-bottom: hidden">
            <tr>
                <td style="width: 800px; font-size: 16px; text-align: center" colspan="5">财务信息区</td>
            </tr>
            <tbody>
                  <tr>
                    <td style="width: 100px; font-size: 16px; text-align: center">结算方式：</td>
                    <td style="width: 700px; text-align: center" colspan="4">
                        <span style="font-size: 16px; font-family: Simsun;" id="lblJSFS">     □ 款到发货            □ 现  付             √ 月 结</span>

                    </td>
                </tr>
                <tr>
                    <td style="width: 100px; font-size: 16px; text-align: center">发票号码/金额：</td>
                    <td style="width: 400px; font-size: 16px; text-align: center">
                        <span style="font-size: 16px; font-family: Simsun;" id="InvoiceNo"></span>
                        <span style="font-size: 16px; font-family: Simsun;" >/</span>
                        <span style="font-size: 16px; font-family: Simsun;" id="InvoiceMoney"></span>
                    </td>
                    <td style="width: 100px; font-size: 16px; text-align: center">交付方式：</td>
                    <td style="width: 200px; text-align: center" colspan="2">
                        <span style="font-size: 16px; font-family: Simsun;" id="DeliveryType">□当面交付 □快递</span>

                    </td>
                </tr>
            </tbody>
        </table>

         <table id="tbSign" style="word-wrap: break-word; word-break: break-all; ">
            <tr>
                <td style="width: 800px; font-size: 16px; text-align: center" colspan="5">签章区</td>
            </tr>
            <tr>
                <td style="width: 200px; font-size: 16px; text-align: center">收发员（签章）
                     <span style="font-size: 16px; font-family: Simsun;" id="FillPerson"></span>
                </td>
                <td style="width: 300px; font-size: 16px; text-align: center">送货人（签章）</td>
                <td style="width: 300px; font-size: 16px; text-align: center" colspan="3">收货人（签章）</td>
            </tr>
             <tr>
                <td style="width: 200px; font-size: 16px; text-align: center">日  期</td>
                <td style="width: 300px; font-size: 16px; text-align: center">日  期</td>
                <td style="width: 300px; font-size: 16px; text-align: center" colspan="3">日  期</td>
            </tr>
        </table>
        <style type="text/css">
            table {
                border-collapse: collapse;
                border: 1px solid;
                margin-left: 40px;
                width: 880px;
            }

            td {
                border: 1px solid;
                font-size: 24px;
                font-family: Simsun,'Times New Roman';
                text-align: left;
            }

            #divPrint span {
                line-height: 26pt;
            }
        </style>

    </div>
</asp:Content>
